/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bionic.commands.user;

import com.bionic.commands.common.ICommand;
import com.bionic.dao.UserDAO;
import com.bionic.entity.Users;
import com.bionic.manager.Config;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Artem
 */
public class CUserPage implements ICommand {

    @Override
    public String execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String page = null;

        UserDAO userDAO = new UserDAO();

        Users user = userDAO.findById(2);
        ArrayList<Users> userList = userDAO.findAll();
        if (user != null) {
            request.setAttribute("userBean", user);
            request.setAttribute("userList", userList);
            page = Config.getInstance().getProperty(Config.USER_FORM);
        } else {
            request.setAttribute("userBean", user);
            page = Config.getInstance().getProperty(Config.ERROR);
        }

        return page;



    }
}
